description: Verify that the GitHub API returns the branches for the React repo
actors:
  - actor: ACTOR1
    segments:
      - segment: 1
        actions:
          - description: Call the GET /repos/:owner/:repo/branches API
            action: org.getopentest.actions.HttpRequest
            args:
              url: https://api.github.com/repos/facebook/react/branches
              verb: GET
              $localData:
                branches: $output.body;
              
          - description: |
              Verify that the branches array was returned and is not empty
            script: |
              var branches = $localData.branches;
              if (!branches || !(branches.length > 0)) {
                  $fail("The response body was invalid or contained no branch elements.");
              } else {
                  $log($format("The GitHub API returned {0} branches", branches.length));
              }